Version:=3.1.0
ModuleName:=dhcp

Objcet:=dhcp.tgz
ObjectDir:=$(ModuleName)-$(Version)/
ObjectSrcDir:=$(ObjectDir)/src/
ObjcetSource:=$(ModuleName)-$(Version).tar.gz

INSTALL_DIR:=`pwd`/tmp/

.PHONY:all clean dist_clean

all:dhcp.tgz

dhcp.tgz:$(ObjcetSource) dhcpd.conf
	tar -xzf $(ObjcetSource)
	rm  -rf  $(INSTALL_DIR)  
	cd $(ObjectDir) && ./configure 
	$(MAKE) -C $(ObjectDir) 
	$(MAKE) -C $(ObjectDir) install DESTDIR=$(INSTALL_DIR)
	cp -rf $(INSTALL_DIR)/sbin/* $(INSTALL_DIR)/usr/sbin/
	rm -rf tmp/etc && mkdir -p tmp/etc && cp -rf dhcpd.conf tmp/etc/
	mv tmp/var/state tmp/usr/state && ln -sf /usr/state tmp/var/state 
	cd $(INSTALL_DIR) && \
	/usr/bin/strip `find ./ -type f  -perm 755 -exec file {} \; | grep "not stripped" | awk -F: '{printf $$1 " "}'` && \
	tar czf dhcp.tgz usr var sbin etc && mv dhcp.tgz ../

clean:
	rm -fr $(Objcet) tmp *.tgz 

dist_clean: clean
	rm -fr $(ObjectDir) $(ObjcetSource) 

include ../Makefile.Res
